import torch
import torchvision

# 1-验证当前设备是否支持GPU
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
print(f'1-current device support {device}')

# 2-验证当前的PyTorch版本和CUDA版本
print(f'2-torch version is {torch.__version__}')  # 打印PyTorch版本
print(f'3-torchvision version is {torchvision.__version__}')  # 打印PyTorchVision版本
print(f'4-torch.version.cuda is {torch.version.cuda}')  # 打印CUDA版本
print(f'5-torch.cuda.is_available is {torch.cuda.is_available()}')  # 打印CUDA是否可用

'''
# 1-未安装CUDA的环境下，输出结果如下：
1-current device support cpu
2-torch version is 2.5.1+cpu
3-torchvision version is 0.20.1+cpu
4-torch.version.cuda is None
5-torch.cuda.is_available is False

# 2-安装CUDA的环境下，输出结果如下：
1-current device support cuda
2-torch version is 2.5.1
3-torchvision version is 0.20.1
4-torch.version.cuda is 11.8
5-torch.cuda.is_available is True
'''
